#region Microsoft Public License
/*
 * (c) Copyright Chenjun Wu. http://utablesdk.codeplex.com
 * 
 * This source is subject to the Microsoft Public License (Ms-PL).
 * Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
 * All other rights reserved.
 */
#endregion

﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace UTable.Objects.Controls
{
    internal class UDecoratorImpl: ControlBaseImpl
    {
        private IControl _child = null;
        private Decorator _owner = null;


        internal new static void OverrideMetadata(Type type)
        {
            ControlBaseImpl.OverrideMetadata(type);
        }

        internal UDecoratorImpl(Decorator owner):base(owner)
        {
            _owner = owner;
        }

        internal void OnSetChild(UIElement child)
        {
            if (_child != null)
            {
                Info.Children.Remove(_child.Info);
                _child.Info.Parent = null;
            }
            if (child is IControl)
            {
                _child = child as IControl;
                Info.Children.Add(_child.Info);
                _child.Info.Parent = Info;
            }
            else
            {
                _child = null;
            }
        }
    }
}
